<extend name="public:base" />

<block name="left">
	<div class="mark_bar cl">
		<a href="{:url('uc/safe/index')}" class="goback fl"><i class="iconfont">&#xe600;</i></a>
		<p>我的银行卡</p>
	</div>
</block>

<block name="main">
	<div class="content">
		<notempty name="bank">
			<div class="bank">
				<div class="bankcard">
					<div class="bankcard_logo">
						<img src="__IMG__/banklogo/{$bank.bank_code|default='default'}.png" class="fl" />
						<span class="fl">{$bank.bank_name|default=''}</span>
						<if condition="session('user_auth.user_type') neq 2">
							<span class="fr">持卡人：*{$bank.bank_user|mb_substr=1,3,'utf-8'}</span>
							<else/>
							<if condition="$bank.bank_user">
								<span class="fr">持卡人：{$bank.bank_user|mb_substr=0,5,'utf-8'}***</span>
								<else/>
								<span class="fr">持卡人：{$bank.enterprise_name|mb_substr=0,5,'utf-8'}***</span>
							</if>
						</if>
						<div class="cl"></div>
					</div>
					<div class="bankcard_num">
						<span>····</span>
						<span>····</span>
						<span>····</span>
						<span>{$bank.card_id|substr=-4,4}</span>
					</div>
				</div>
				<div class="bank_card_btm">
					<if condition="session('user_auth.user_type') neq 2">
						<a href="{:url('change_phone')}" class="half">更新预留手机号 </a>
					</if>
					<a href="javascript:movetop('checkInfo');" <if condition="session('user_auth.user_type') neq 2">class="half"</if>>解绑银行卡</a>
				</div>
			</div>

			<div id="checkInfo" class="openframe hide">
				<div class="mark_bar invest_mark_bar">
					<a href="javascript:;" onclick="movebot('checkInfo');" class="goback fl"><i class="iconfont">&#xe602;</i></a>
					<p>确认身份信息</p>
				</div>
				<div class="openframe_content">
					<div class="unbindBank">
						<form action="{:url('uc/bank/unbind_bankcard')}" method="post" id="form">
							<input type="tel" class="input" autocomplete="off" name="id_card" value="" id="idcard" placeholder="身份证号" />
							<input type="text" class="input" autocomplete="off" name="card_id" value="" id="card_id" placeholder="银行卡号" />
							<input type="submit" value="确定" class="submit" />
						</form>
					</div>
				</div>
			</div>

			<else/>

			<if condition="session('user_auth.user_type') eq 2">
				<form action="{:url('uc/bank/bind_bankcard')}" method="post" id="addForm">
					<div class="bind_card from">
						<input type="hidden" id="bank_code" name="bank_code" />
						<div class="input_form">
							<div class="input_form_bar">
								<p class="fl">公司名称</p>
								<input type="text" disabled value="{$info.enterprise_name}" autocomplete="off" style="font-style: normal;" />
								<div class="cl"></div>
							</div>
							<div class="input_form_bar">
								<p class="fl">开户银行</p>
								<select id="selectBank">
									<volist name="bank_list" id="v">
										<option value="{$v.bank_code}">{$v.bank_name}</option>
									</volist>
								</select>
								<div class="cl"></div>
							</div>
							<div class="input_form_bar">
								<p class="fl">对公帐号</p>
								<input type="number" id="publicBank" name="card_id" placeholder="请输入储蓄卡卡号" autocomplete="off" />
								<div class="cl"></div>
							</div>
						</div>

						<div class="wrap">
							<button class="submit nor" type="submit">确定</button>
						</div>
					</div>
				</form>
				<else/>
				<form action="{:url('uc/bank/bind_bankcard')}" method="post">
					<a href="javascript:void(0);" class="addBankBtn">
						<i class="icon"></i>
						<p><i class="iconfont">&#xe624;</i>添加银行卡</p>
						<input type="submit" value="submit" />
					</a>
				</form>
			</if>

		</notempty>
	</div>

</block>

<block name="menu"></block>

<block name="js">
	<script type="text/javascript" src="__JS__/check.js?v={:config('app_ver')}"></script>
	<script type="text/javascript">
		$(function () {

			$("#form").submit(function () {
				if(!checkIdcard()) return false;
				if(!checkBankcard()) return false;
			});

			$("#addForm").submit(function () {
                if(!checkPublicBank()) return false;
            });

            $("#selectBank").each(function () {
                var selected = $(this).find("option:selected");
                $("#bank_code").val(selected.val());
                $(this).change(function () {
                    $("#bank_code").val($(this).val());
                });
            })
		})
	</script>
</block>